home *** CD-ROM | disk | FTP | other *** search
/ Network Support Library / RoseWare - Network Support Library.iso / apidev / sc3x04.exe / SCTRUST.C < prev    next >
C/C++ Source or Header  |  1993-04-09  |  4KB  |  112 lines

  1. //   ╔════════════════════════════════════════════════════════════════════╗
  2. //   ║                                                                    ║
  3. //   ║ module:      sctrust.c                                             ║
  4. //   ║ abstract:    This module shows how to make 3.x system calls using  ║
  5. //   ║              the F2 Shell Interface for the ScanEntryForTrustees   ║
  6. //   ║              API, obviously it requires the NetWare Shell.         ║
  7. //   ║                                                                    ║
  8. //   ║              This call may need to be made iteratively to return   ║
  9. //   ║              all of the trustee information.  For simplicity,      ║
  10. //   ║              this example only makes the call once.                ║
  11. //   ║                                                                    ║
  12. //   ║              Whatever pathname is entered must be for the          ║
  13. //   ║              currently logged drive, as this is not checked.       ║
  14. //   ║              Wildcard expressions are not supported.               ║
  15. //   ║                                                                    ║
  16. //   ║ environment: NetWare 3.x v3.11                                     ║
  17. //   ║              Borland C++ 3.1                                       ║
  18. //   ║                                                                    ║
  19. //   ║  This software is provided as is and carries no warranty           ║
  20. //   ║  whatsoever.  Novell disclaims and excludes any and all implied    ║
  21. //   ║  warranties of merchantability, title and fitness for a particular ║
  22. //   ║  purpose.  Novell does not warrant that the software will satisfy  ║
  23. //   ║  your requirements or that the software is without defect or error ║
  24. //   ║  or that operation of the software will be uninterrupted.  You are ║
  25. //   ║  using the software at your risk.  The software is not a product   ║
  26. //   ║  of Novell, Inc. or any of subsidiaries.                           ║
  27. //   ║                                                                    ║
  28. //   ╚════════════════════════════════════════════════════════════════════╝
  29. //   
  30. //                         ****** N O T I C E ******
  31. //
  32. //     This software is considered pre-release and may be used at your own
  33. //     risk and has been provided due to the many requests of our cust-
  34. //     omers.  Support for this module will be provided at the sole
  35. //     discretion of Novell, Inc.
  36. //
  37.  
  38. #include <stdio.h>
  39. #include <string.h>
  40. #include <dos.h>
  41. #include <dir.h>
  42.  
  43. #include "nwsys.h"
  44.  
  45. struct REQUEST {
  46.     WORD sfLen;        // length of the structure
  47.     BYTE sfCode;       // subfunction code
  48.     BYTE dirHandle;    // directory handle
  49.     BYTE sequence;     // starting set number
  50.     BYTE pathLength;   // directory path length
  51.     BYTE path[255];    // directory path buffer
  52. } request;
  53.  
  54. struct REPLY {
  55.     BYTE numEntries;   // number of trustee sets returned
  56.     LONG objectID[20]; // trustee object ID
  57.     WORD rights[20];   // trustee rights
  58. } reply;
  59.  
  60. BYTE GetDirectoryHandle(int diskNumber)
  61. {
  62.     union   REGS    regs;
  63.  
  64.     memset(®s, 0, sizeof(regs));
  65.  
  66.     regs.h.ah = 0xe9;
  67.     regs.h.al = 0x00;
  68.     regs.x.dx = diskNumber;
  69.  
  70.     intdos(®s,®s);       // do the Int 21
  71.  
  72.     return(regs.h.al);         // return code is in AL
  73. }
  74.  
  75. int main()
  76. {
  77.     int i, retCode, diskNumber;
  78.     WORD serverConnectionID;
  79.     BYTE dirHandle;
  80.     char fileName[80];
  81.  
  82.     printf("Pathname and/or filename to scan: ");
  83.     gets(fileName);
  84.  
  85.     diskNumber = getdisk();
  86.  
  87.     dirHandle = GetDirectoryHandle(diskNumber);
  88.  
  89.     request.sfLen = sizeof(request);
  90.     request.sfCode = 0x26;
  91.     request.dirHandle = dirHandle;
  92.     request.sequence = 0;
  93.     strcpy(request.path, fileName);
  94.     request.pathLength = strlen(request.path);;
  95.     retCode = NWSystemCall(0x16, &request, sizeof(request),
  96.                                  &reply,   sizeof(reply));
  97.     if (retCode == 0) {
  98.         printf("%d trustee sets returned.\n", reply.numEntries);
  99.         printf("Trustee ID   Rights\n");
  100.         for (i = 0; i < reply.numEntries; i++)
  101.             printf("%10lu   0x%x\n", reply.objectID[i], reply.rights[i]);
  102.     }
  103.     else if (retCode == 156) 
  104.         printf("No trustees exist for this entry.\n");
  105.     else {
  106.         printf("ScanEntryForTrustees call failed.  Return code = %d.\n",
  107.             retCode);
  108.         return(1);
  109.     }
  110.     return(0);
  111. }
  112.